package com.dc.controller;

import com.dc.annotation.Log;
import com.dc.common.ResponseResultVO;
import com.dc.entity.InspectionPosition;
import com.dc.entity.ro.InspectionPositionRO;
import com.dc.service.InspectionPositionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

@Api(tags = "巡检点位管理")
@RestController
@RequestMapping("/inspectionPosition")
public class InspectionPositionController {

    @Resource
    private InspectionPositionService inspectionPositionService;


    @ApiOperation(value = "批量生成区域二维码zip", notes = "批量生成区域二维码zip")
    @RequestMapping(value = "/batchCreateAddressQrCode", method = RequestMethod.GET)
    public ResponseResultVO batchCreateAddressQrCode(@RequestParam Integer num, HttpServletResponse response) {
        return inspectionPositionService.batchCreateAddressQrCode(num, response);
    }

    @Log(title = "巡检点位管理", businessDesc = "增加")
    @ApiOperation(value = "增加", notes = "增加")
    @PostMapping("/insertInspectionPosition")
    public ResponseResultVO insertInspectionPosition(@RequestBody InspectionPositionRO ro) {
        return inspectionPositionService.insertInspectionPosition(ro);
    }


    @Log(title = "巡检点位管理", businessDesc = "修改")
    @ApiOperation(value = "修改", notes = "修改")
    @PostMapping("/updateInspectionPosition")
    public ResponseResultVO updateInspectionPosition(@RequestBody InspectionPositionRO ro) {
        return inspectionPositionService.updateInspectionPosition(ro);
    }


    @Log(title = "巡检点位管理", businessDesc = "更新二维码")
    @ApiOperation(value = "更新二维码", notes = "更新二维码")
    @PostMapping("/updateQrCode")
    public ResponseResultVO updateQrCode(String id) {
        return inspectionPositionService.updateQrCode(id);
    }


    @Log(title = "巡检点位管理", businessDesc = "删除")
    @ApiOperation(value = "删除", notes = "删除")
    @GetMapping("/deleteInspectionPosition")
    public ResponseResultVO deleteInspectionPosition(@RequestParam String id) {
        return inspectionPositionService.deleteInspectionPosition(id);
    }

    @ApiOperation(value = "查询列表", notes = "查询列表")
    @PostMapping("/selectPositionListByPage")
    public ResponseResultVO<InspectionPosition> selectPositionListByPage(@RequestBody InspectionPositionRO ro) {
        return inspectionPositionService.selectPositionListByPage(ro);
    }

    @ApiOperation(value = "查询巡检点位下拉列表", notes = "查询巡检点位下拉列表")
    @GetMapping("/selectInspectionPositionList")
    public ResponseResultVO<InspectionPosition> selectInspectionPositionList() {
        return inspectionPositionService.selectInspectionPositionList();
    }
}
